package com.GourmetDataBase;

import java.io.IOException;
import java.util.List;

import com.Gourmet.ListadoGenerosComida;
import com.Gourmet.R;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;

public class ObtenerConexion {
	//Luis
	//Paul
	//Herbert
	Context context;

	public ObtenerConexion(Context context){
		this.context=context;
	}
	
	public  SQLiteDatabase getsqliteDatabase(){
		
		GourmetDatabaseHelper myDbHelper=null;
		SQLiteDatabase db = null;
		try {
		 myDbHelper = new GourmetDatabaseHelper(context);
		 myDbHelper.createDataBase();
		 myDbHelper.openDataBase();
		  db = myDbHelper.getWritableDatabase();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return db;
	}

	public Cursor obtenerListadoGenerosComida() {
		// TODO Auto-generated method stub
		return getsqliteDatabase().rawQuery("SELECT _id,descripcion FROM tb_generosComida", null);
	}

	public Cursor ObtenerRestaurant(String[] parametro) {
		// TODO Auto-generated method stub
		return getsqliteDatabase().rawQuery("SELECT _id,descripcion, detalle, longitud, latitud, direccion, idGenero, rating FROM tb_restauranes  WHERE idGenero=? ORDER BY rating DESC", parametro);	}

	public Cursor ObtenerLogos() {
		// TODO Auto-generated method stub
		return getsqliteDatabase().rawQuery("SELECT idRestaurant,descripcion FROM tb_logos ",null);
	}

	public Cursor obtenerImagenes(String[] parametro) {
		// TODO Auto-generated method stub
		return getsqliteDatabase().rawQuery("SELECT descripcion FROM tb_imagenes WHERE idRestaurant=?",  parametro);
	}
	
	
	
}
